package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.MemberDto;
import com.itheima.pojo.OrderVo;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;
    @GetMapping("/findById")
    public Result findById(Long id){
        OrderVo orderVo=orderService.findById(id);
        return new Result(true, MessageConstant.QUERY_ORDER_SUCCESS,orderVo);
    }
    @PostMapping("/submitOrder")
    public Result submitOrder(MemberDto memberDto){
        String code= orderService.submitOrder(memberDto);
        return new Result(true, MessageConstant.ORDER_SUCCESS,null);
    }
}
